home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Fab Libraries / Utils.h < prev    next >
Encoding:
Text File  |  1994-01-08  |  7.2 KB  |  239 lines  |  [TEXT/MPS ]

  1. /*
  2. comment out the #define below to obtain a System 6
  3. compatible version of some libraries.
  4. If you #define FabSystem7orlater, the libraries get
  5. smaller (the code needed under System 6 only is
  6. stripped out). */
  7. //
  8. #define    FabSystem7orlater    1
  9.  
  10. #if defined(FabSystem7orlater)
  11.  
  12. #define    FabFSpCreate    FSpCreate
  13. #define    FabFSpOpenDF    FSpOpenDF
  14. #define    FabFSpDelete    FSpDelete
  15. #define    FabStandardPutFile    StandardPutFile
  16.  
  17. #else
  18.  
  19. #include    "Utils6.h"
  20.  
  21. #endif
  22.  
  23.  
  24. pascal OSErr SetLabel(short labelNumber, const RGBColor *, ConstStr255Param)
  25.     = {0x303C, 0x050C, 0xABC9};
  26.  
  27. #pragma parameter __D0 PBEjectAsync(__A0)
  28. pascal OSErr PBEjectAsync(ParmBlkPtr paramBlock)
  29.     = 0xA417; 
  30.  
  31. /* Returns a pointer to the Dialog Manager’s standard dialog filter */
  32. pascal OSErr GetStdFilterProc(ModalFilterProcPtr *theProc )
  33.     = { 0x303C, 0x0203, 0xAA68 };
  34.  
  35. /* Indicates to the Dialog Manager which item is default.  Will then alias the return */
  36. /* & enter keys to this item, and also bold border it for you (yaaaaa!) */        
  37. pascal OSErr SetDialogDefaultItem(DialogPtr theDialog, short newItem) 
  38.     = { 0x303C, 0x0304, 0xAA68 };        
  39.  
  40. /* Indicates which item should be aliased to escape or Command - . */
  41. pascal OSErr SetDialogCancelItem(DialogPtr theDialog, short newItem)
  42.     = { 0x303C, 0x0305, 0xAA68 };
  43.  
  44. /* Tells the Dialog Manager that there is an edit line in this dialog, and */ 
  45. /* it should track and change to an I-Beam cursor when over the edit line */
  46. pascal OSErr SetDialogTracksCursor(DialogPtr theDialog, Boolean tracks)
  47.     = { 0x303C, 0x0306, 0xAA68 };
  48.  
  49. #define topLeft(r)        (((Point *) &(r))[0])
  50. #define botRight(r)        (((Point *) &(r))[1])
  51.  
  52. pascal Boolean OSSTDFILTERPROC(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
  53.  
  54. /* a little bit of work Apple should have done in the first place in the headers */
  55.  
  56. #pragma parameter __D0 MySetApplLimit(__A0)
  57. pascal short MySetApplLimit(void *zoneLimit)
  58.     = 0xA02D; 
  59.  
  60. #pragma parameter __D0 MyDelay(__A0)
  61. pascal long MyDelay(long numTicks)
  62.     = {0xA03B}; 
  63.  
  64. #pragma parameter MyNumToString(__D0,__A0)
  65. pascal void MyNumToString(long theNum,Str255 theString) = {0x4267, 0xA9EE };
  66.  
  67. #pragma parameter __D0 MyStringToNum(__A0)
  68. pascal long MyStringToNum(ConstStr255Param theString) = {0x3F3C, 0x0001, 0xA9EE };
  69.  
  70. #pragma parameter __D0 FabDate2Secs(__A0)
  71. pascal long FabDate2Secs(const DateTimeRec *date)
  72.  = _Date2Secs; 
  73.  
  74. pascal long FabSndSoundManagerVersion(void)
  75.     = {0x203C,0x000C,0x0008,0xA800}; 
  76.  
  77. /* WantThisHandleSafe locks high the handle and returns the previous state */
  78.  
  79. #pragma parameter __D0 WantThisHandleSafe(__A0)
  80. pascal SignedByte WantThisHandleSafe(Handle myH) = {0xA069, 0x1F00, 0xA064, 0xA029, 0x101F};
  81.  
  82. /* ClearHiliteMode clears the HiliteMode bit with BCLR */
  83.  
  84. pascal void ClearHiliteMode(void) = {0x08B8, 0x0007, 0x0938};
  85.  
  86.  
  87. #define numOfLongs(s)    (((s)>>2) - 1L)
  88.  
  89. #pragma parameter MyZeroBuffer(__A0,__D1)
  90. pascal void MyZeroBuffer(Ptr p, long s) = {0x7000, 0x20C0, 0x51C9, 0xFFFC };
  91.  
  92. #pragma parameter MyFillBuffer(__A0,__D1,__D0)
  93. pascal void MyFillBuffer(Ptr p, long s, long filler) = {0x20C0, 0x51C9, 0xFFFC };
  94.  
  95.  
  96. #pragma parameter __D0 mySwap(__D0)
  97. pascal long mySwap(long s) = {0x4840 };
  98.  
  99. #pragma parameter __D0 Ext12(__D0)
  100. pascal short Ext12(short s) = {0xE948, 0xE840 };
  101.  
  102. #pragma parameter __D0 Ext11(__D0)
  103. pascal short Ext11(short s) = {0xEB48, 0xEA40 };
  104.  
  105.  
  106. #define    CHARFROMMESSAGE(mess)    (*(((unsigned char *)(&(mess))) + 3))
  107.  
  108. /* strings */
  109. enum simplestrings {
  110. kSTR_NOOPENORPRINT = -16397,
  111. kSTR_ApplicationName = -16396
  112. };
  113.  
  114. enum {
  115. kEscapeKey = 0x351B
  116. };
  117.  
  118. /* for KeyState */
  119. enum {
  120. kCommandKeyCode = 55,
  121. kShiftKeyCode,
  122. kCapsLockKeyCode,
  123. kOptionKeyCode,
  124. kControlKeyCode
  125. };
  126.  
  127. enum {
  128. kWantRestart = false,
  129. kWantShutdown = true
  130. };
  131.  
  132. enum {
  133. kCreat = 'FABR',
  134. kAEAlert = 'ALRT'
  135. };
  136.  
  137. enum {
  138. kSTR_RegDECALLOWED = 302,
  139. kDLOG_Register = 300,
  140. kALRT_REGCANNOTREPLACE = 201,
  141. kALRT_REGSUCCESSSAVED = 202,
  142. kALRT_REGDISKFULL = 203,
  143. kALRT_REGUNKNOWNWRITEERROR = 204,
  144. kALRT_REGCOULDNOTOPENFORWRITING = 205,
  145. kALRT_REGCOULDNOTCREATE = 206,
  146. kItemUserName = 3,
  147. kItemCompany,
  148. kItemAddress,
  149. kItemCity,
  150. kItemState,
  151. kItemZIP,
  152. kItemCountry,
  153. kItemE_mail,
  154. kItemPhone,
  155. kItemFAX,
  156. kItemQuantity,
  157. kItemCopyFrom,
  158. kItemComments,
  159. kItemTotals = 28
  160. };
  161.  
  162. OSErr AddSTRRes2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, short STRid, ScriptCode lScript);
  163. OSErr AddSTRHand2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, StringHandle msgString, ScriptCode lScript);
  164. OSErr AddRes2Doc(FSSpec *theDoc, Handle thisHandle, ResType rType, short rID);
  165. void SendmyAE(AEEventClass, AEEventID myAEvtID, IdleProcPtr, AESendMode theMode);
  166. void SendmyAEPShort(AEEventClass myclass, AEEventID myAEvtID, IdleProcPtr IdleFunct, AESendMode theMode, short theAlert);
  167. void ZoomRectToRect(RectPtr startingRect, RectPtr endingRect, short numofDivs);
  168. Handle NewHandleGeneral(Size blockSize);
  169. Handle Get1ResGeneral(ResType theType, short theID);
  170. OSType FindFinderAtEaseProcess(ProcessSerialNumber *);
  171. OSType FindFinderProcess(void);
  172. OSErr SendShutdownToFinder(IdleProcPtr, Boolean);
  173. short FabStopAlert(short alertID, ModalFilterProcPtr filterProc, IdleProcPtr IdleFunct);
  174. short FabCautionAlert(short alertID, ModalFilterProcPtr filterProc, IdleProcPtr IdleFunct);
  175. short FabNoteAlert(short alertID, ModalFilterProcPtr filterProc, IdleProcPtr IdleFunct);
  176. short FabAlert(short alertID, ModalFilterProcPtr filterProc, IdleProcPtr IdleFunct);
  177.  
  178. typedef struct {
  179.     FSSpec    destFile;
  180.     ScriptCode    theScript;
  181.     } StdFileResult, *StdFileResultPtr;
  182.  
  183. /* dialog box manager */
  184.  
  185. struct dialogitems {
  186.     short    itemNumber;
  187.     short    group;
  188.     long    refCon;
  189.     };
  190.  
  191. typedef struct dialogitems dialogItems, *dialogItemsPtr;
  192.  
  193. void FlashButton(DialogPtr dlg, short item);
  194. void OutlineButton(DialogPtr oftheDialog, short myItem);
  195.  
  196. short HandleDialog(ModalFilterProcPtr filterProc,
  197.                     dialogItemsPtr things,
  198.                     void (*initProc)(DialogPtr),
  199.                     void (*userProc)(DialogPtr, Handle, short),
  200.                     short resId);
  201.  
  202. /* about box manager */
  203.  
  204. void myAbout(void (*theIdleProc)(void),
  205.             pascal void (*DrawQTPict)(DialogPtr, short),
  206.             void (*UpdateProc)(EventRecord *),
  207.             void (*ActivateProc)(EventRecord *)
  208.             );
  209. Handle OpenSplash(DialogPtr *, pascal void (*DrawQTPict)(DialogPtr, short));
  210. void DisposeSplash(Handle, DialogPtr);
  211.  
  212. Boolean GetFontNumber(ConstStr255Param fontName, short *fontNum);
  213. OSErr TickleParent( FSSpec *child );
  214. Boolean CmdPeriod(EventRecord *theEvent);
  215. Boolean CmdPeriodOrEsc(EventRecord *theEvent);
  216. Boolean CmdPeriodOrEscConfirm(EventRecord *theEvent, short alertID, ModalFilterProcPtr filterProc);
  217. void HandleRegistration(ModalFilterProcPtr filterProc,
  218.                         long (*regCfgInfo)(Handle, long, StringPtr),
  219.                         short dollars);
  220. void RegInitProc(DialogPtr myDPtr);
  221. OSErr AskForDestFile(StdFileResultPtr whichFile);
  222. void BCDVersNumToString(long num, StringPtr str);
  223. void BCDLongVersNumToString(long num, StringPtr str);
  224. Boolean TrapAvailable(short theTrap);
  225.  
  226. // asm routines, indexes are zero-based
  227.  
  228. StringPtr GetPtrIndHString(Handle resH, short index);
  229. void GetIndHString(Str255 *dest, Handle resH, short index);
  230.  
  231. pascal Ptr ShortToHexText(short, Ptr);
  232. pascal void ShortToHexString(short, Str255);
  233. pascal void ShortToOctString(short, Str255);
  234. pascal void ShortToBinString(short num, Str255 result);
  235. pascal void HexStringToShort(ConstStr255Param, short *);
  236. pascal void OctStringToShort(ConstStr255Param, short *);
  237. pascal void BinStringToShort(ConstStr255Param, short *);
  238. Boolean KeyState(short key);
  239.